package com.woniuxy.merchant.config; // 根据实际情况调整包路径

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
public class AutoFill implements MetaObjectHandler {

    @Override
    public void insertFill(MetaObject metaObject) {
        System.out.println("Insert operation detected, auto-filling 'register_time' and 'last_login'");
        this.strictInsertFill(metaObject, "creatTime", LocalDateTime.class, LocalDateTime.now());
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        // 如果有需要，在更新时自动填充其他时间字段，如 last_login
        // 注意：这里的字段名和类型需要根据实际需求调整
        this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
    }
}